// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.TransformManagement
{
	public sealed partial class Destination
	{
		[JsonInclude]
		[JsonPropertyName("index")]
		public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; }

		[JsonInclude]
		[JsonPropertyName("pipeline")]
		public string? Pipeline { get; set; }
	}

	public sealed partial class DestinationDescriptor : SerializableDescriptorBase<DestinationDescriptor>
	{
		internal DestinationDescriptor(Action<DestinationDescriptor> configure) => configure.Invoke(this);
		public DestinationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.IndexName? IndexValue { get; set; }

		private string? PipelineValue { get; set; }

		public DestinationDescriptor Index(Elastic.Clients.Elasticsearch.IndexName? index)
		{
			IndexValue = index;
			return Self;
		}

		public DestinationDescriptor Pipeline(string? pipeline)
		{
			PipelineValue = pipeline;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (IndexValue is not null)
			{
				writer.WritePropertyName("index");
				JsonSerializer.Serialize(writer, IndexValue, options);
			}

			if (!string.IsNullOrEmpty(PipelineValue))
			{
				writer.WritePropertyName("pipeline");
				writer.WriteStringValue(PipelineValue);
			}

			writer.WriteEndObject();
		}
	}
}